<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>内存中的图象数据(Image Data in Memory)</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK-PixBuf 库参考手册">
<link rel="up" href="rn01.html" title="API 参考">
<link rel="prev" href="gdk-pixbuf-file-saving.html" title="保存文件(File saving)">
<link rel="next" href="gdk-pixbuf-inline.html" title="内联数据 (Inline data)">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk-pixbuf-file-saving.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK-PixBuf 库参考手册</th>
<td><a accesskey="n" href="gdk-pixbuf-inline.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk-pixbuf-creating.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk-pixbuf-creating.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk-pixbuf-creating"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-pixbuf-creating.top_of_page"></a>内存中的图象数据(Image Data in Memory)</span></h2>
<p>内存中的图象数据(Image Data in Memory) — 使用内存中的数据创建一个 pixbuf 。</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk-pixbuf-creating.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;

<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()">gdk_pixbuf_new</a>                      (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()">gdk_pixbuf_new_from_data</a>            (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> rowstride</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-refcounting.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> destroy_fn_data</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()">gdk_pixbuf_new_from_xpm_data</a>        (<em class="parameter"><code>const <span class="type">char</span> **data</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-inline" title="gdk_pixbuf_new_from_inline ()">gdk_pixbuf_new_from_inline</a>          (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> data_length</code></em>,
                                                         <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#guint8"><span class="type">guint8</span></a> *data</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> copy_pixels</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-subpixbuf" title="gdk_pixbuf_new_subpixbuf ()">gdk_pixbuf_new_subpixbuf</a>            (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *src_pixbuf</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_x</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_y</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()">gdk_pixbuf_copy</a>                     (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-creating.description"></a><h2>Description</h2>
<p>
    创建一个 pixbuf 的最基本的方法是使用 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> 结构包装(wrap)一个已经
    存在的像素缓冲区(pixel buffer)。可以使用<a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a>函数
    来完成。但需要指定销毁通知函数(destroy notification function)，该函数
    在这个数据缓冲区需要被释放的时候调用--这将在一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> 被引用计数析构
    的时候发生。如果有被编译进程序内部的静态数据，可以传递 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> 作为销毁通知函数
    以使这些数据不被释放。
  </p>
<p>
    函数 <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()"><code class="function">gdk_pixbuf_new()</code></a> 可以作为一个从空的缓冲区(buffer)创建 pixbuf 的便捷
    途径。这等同于使用 <code class="function"><code class="function">malloc()</code></code> 创建一个数据缓冲区，然后
    使用 <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a> 包装(wrapping)它。函数 <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()"><code class="function">gdk_pixbuf_new()</code></a>
    会计算一个优化的行跨度(rowstride)以使得渲染可以更有效率的进行。
  </p>
<p>
    作为一个特例，可以使用 <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()"><code class="function">gdk_pixbuf_new_from_xpm_data()</code></a> 函数从内联的
    XPM 图像数据创建一个 pixbuf 。
  </p>
<p>
    也可以使用函数 <a class="link" href="gdk-pixbuf-creating.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()"><code class="function">gdk_pixbuf_copy()</code></a> 来拷贝一个已经存在的 pixbuf。这与只
    对老的 pixbuf 进行 <a href="../gobject/gobject-The-Base-Object-Type.html#g-object-ref"><code class="function">g_object_ref()</code></a> 不同 -- 拷贝函数实际上会为像素数据在内存中
    创建一个副本并为其创建一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> 结构。
  </p>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-creating.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="gdk-pixbuf-new"></a><h3>gdk_pixbuf_new ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new                      (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);</pre>
<p>
创建一个新的 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> 结构并为其分配一个缓冲区。该缓冲区为行优化的。注意该
缓冲区并不是空的，需要你自己完全填充。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorspace</code></em> :</span></p></td>
<td>Color space for image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>has_alpha</code></em> :</span></p></td>
<td>Whether the image should have transparency information</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>bits_per_sample</code></em> :</span></p></td>
<td>Number of bits per color sample</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>Width of image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>Height of image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>一个新创建的 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>，其引用数为1，如果内存不足以分配这个图
像缓冲区则返回 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>。</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-data"></a><h3>gdk_pixbuf_new_from_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_from_data            (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> rowstride</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-refcounting.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> destroy_fn_data</code></em>);</pre>
<p>
从内存中的图像数据创建一个新的 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>。当前只支持 8 bits／sample 的RGB图
像。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Image data in 8-bit/sample packed format</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorspace</code></em> :</span></p></td>
<td>Colorspace for the image data</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>has_alpha</code></em> :</span></p></td>
<td>Whether the data has an opacity channel</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>bits_per_sample</code></em> :</span></p></td>
<td>Number of bits per sample</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>Width of the image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>Height of the image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>rowstride</code></em> :</span></p></td>
<td>Distance in bytes between row starts</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_fn</code></em> :</span></p></td>
<td>Function used to free the data when the pixbuf's reference count
drops to zero, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the data should not be freed. <span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_fn_data</code></em> :</span></p></td>
<td>Closure data to pass to the destroy notification function</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference count of 1. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-xpm-data"></a><h3>gdk_pixbuf_new_from_xpm_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_from_xpm_data        (<em class="parameter"><code>const <span class="type">char</span> **data</code></em>);</pre>
<p>
通过解析内存中的 XPM 数据创建一个新的 pixbuf。该数据通常是在程序的C源码中包含
了一个 XPM 文件的结果。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>指向一个内联的 XPM 数据</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>一个新创建的 pixbuf，引用数为 1。</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-inline"></a><h3>gdk_pixbuf_new_from_inline ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_from_inline          (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> data_length</code></em>,
                                                         <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#guint8"><span class="type">guint8</span></a> *data</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> copy_pixels</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
从一个适合于使用内嵌数据保存在程序中的平面画像(flat representation)创建一个 
<a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> 。这将在想包装(ship)一个带图像的程序，又不想依赖任何的外部文件时非
常有用。
</p>
<p>
gdk-pixbuf ships with a program called <span class="command"><strong>gdk-pixbuf-csource</strong></span> 
which allows for conversion of <a href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbufs</span></a> into such a inline representation.
In almost all cases, you should pass the <code class="option">--raw</code> flag to
<span class="command"><strong>gdk-pixbuf-csource</strong></span>. A sample invocation would be:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
 gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
</pre></div>
<p>
</p>
<p>
在典型的内嵌的 pixbuf 是只读静态数据的情况下，并不需要拷贝 pixel data， 除非
打算对其进行写操作，所以可以给 <em class="parameter"><code>copy_pixels</code></em> 传递 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> 。(如果给 
<span class="command"><strong>gdk-pixbuf-csource</strong></span> 设置了 <code class="option">--rle</code> ，则即便 
<em class="parameter"><code>copy_pixels</code></em> 是 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>，将仍然会拷贝数据，所以一般来说使用这个选项并不是个好
主意)。
</p>
<p>
如果从程序中的编译过的常量内嵌数据创建一个 pixbuf，忽略错误和禁止长度检查有可
能是安全的，因为转换肯定会成功。 
</p>
<div class="informalexample"><pre class="programlisting">
pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL);
</pre></div>
<p>
</p>
<p>
For non-const inline data, you could get out of memory. For untrusted 
inline data located at runtime, you could have corrupt inline data in 
addition.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_length</code></em> :</span></p></td>
<td>
<em class="parameter"><code>data</code></em>参数的字节长度或-1可以禁止长度检查</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>字节数据包含一个连续的<a class="link" href="gdk-pixbuf-inline.html#GdkPixdata" title="struct GdkPixdata"><span class="type">GdkPixdata</span></a>结构</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>copy_pixels</code></em> :</span></p></td>
<td>拷贝pixel数据，或使用直接指针<em class="parameter"><code>data</code></em>作为pixbuf的结果</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>
<a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> 返回位置，也许<a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> 可以忽略错误</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>一个新创建的 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>， 其引用数为1，出错时返回 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>。</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-subpixbuf"></a><h3>gdk_pixbuf_new_subpixbuf ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_subpixbuf            (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *src_pixbuf</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_x</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_y</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);</pre>
<p>
为 <em class="parameter"><code>src_pixbuf</code></em> 的一个子区域创建一个新的 pixbuf。这个新的 pixbuf 与原始 
pixbuf 共享像素，所以向其中一个写数据将同时影响这两个。新的 pixbuf 持有一个
对 <em class="parameter"><code>src_pixbuf</code></em> 的引用，所以在该新的 pixbuf 被 finalized 前 <em class="parameter"><code>src_pixbuf</code></em> 不应该
被 finalized。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_x</code></em> :</span></p></td>
<td>
<em class="parameter"><code>src_pixbuf</code></em> 的X坐标</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_y</code></em> :</span></p></td>
<td>
<em class="parameter"><code>src_pixbuf</code></em> 的Y坐标</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>
<em class="parameter"><code>src_pixbuf</code></em> 区域的宽度</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>
<em class="parameter"><code>src_pixbuf</code></em> 区域的高度</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a new pixbuf. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-copy"></a><h3>gdk_pixbuf_copy ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_copy                     (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);</pre>
<p>
创建一个指定的 <em class="parameter"><code>pixbuf</code></em> 的副本。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 pixbuf.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created pixbuf with a reference count of 1, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if
not enough memory could be allocated. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-creating.see-also"></a><h2>See Also</h2>
<p>
    <code class="function">gdk_pixbuf_finalize()</code>.
  </p>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>